Skip to content

fix(console): a related tab's New keeps the parent it prefills when the child's relationship lookup declares dependsOn - #37283

Merged
objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/issue-37246-related-new-dependson-prefill
Nov 25, 2026
Merged

objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/issue-37246-related-new-dependson-prefill

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #37246
Clause-②: yes (widening) — one new export, relatedCreateSeedOf, on the published @object-ui/plugin-detail/core subpath; nothing is removed or renamed, and the package root exports the same names as before
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:在记录页的相关页签点「添加 → 新建」建子记录时,预填的父记录(如订单、商机)不再被藏在「请先选择客户」后面或被清空,客户字段一并带入,保存后子记录正确挂在父记录下。
  • 为什么做:子对象的关系字段声明「依赖于客户」后,页签里新建会把预填的父记录藏在「请先选择客户」后面;若该字段还配了自动带出客户,打开表单时父记录会被清空,并且不报错地存成未关联的记录。这也挡住了 HotCRM 让「添加」只列同一客户记录的改动(HotCRM 那张 p1 卡)。
  • 出错会怎样:只影响新建表单打开时带入的初始值;没有声明依赖的关系、父记录没有客户值时,行为与今天完全一样;可直接撤回本次改动。
  • 要你做什么:无。

What changes

A record page's related tab, New (the header's, or the one inside the Add picker), opened the child's create form with the parent link alone. When the child's relationship lookup declares dependsOn (a billing milestone's order dependsOn the milestone's account), the form drew the lookup gated ("Select Account first", the parent hidden); with a lookupAutofill that fills the account from the order, the opening fill wrote the account and the form's dependent-lookup clear then emptied the order, and Create saved the child with crm_sales_order: null, no error shown.

Root cause: the New path seeded only the parent link (formLink = one FIELD:ID pair). The lookup's own + New already seeds its dependsOn values (#35050) and the derived Add picker already scopes by them (#36729); the tab's New did neither.

Fix (smallest change, one copy of the relation logic):

  • ui/packages/plugin-detail/src/relatedParentScope.ts (new, pure, exported on /core only, the subpath its one consumer imports): dependsOnFromParent is the dependsOn inversion parentScopeOf used to carry inline, moved here unchanged; relatedCreateSeedOf(childFields, referenceField, parentRecord) reads the same pairs as values. RelatedList.tsx's parentScopeOf now calls dependsOnFromParent, so the picker scope and the New seed cannot drift.
  • ui/packages/app-shell/src/views/RelatedRecordActionsBridge.tsx: onCreate adds the seed to the link; openChildForm writes the parent pair first, then one formLink pair per seeded value (refresh-safe, like the link). A custom page's lists (parentFromList) name their own parents, which this bridge does not hold, so they keep the link alone.
  • ui/packages/app-shell/src/console/AppContent.tsx: the overlay reads every formLink pair (first pair of a field wins, a malformed pair is skipped) into the create's opening values. urlParams.ts documents the repeat.
  • ui/apps/console/vite.config.ts: the new module joins the plugin-detail-core chunk group, as that file requires for every module in the /core closure.

Unblocks objectstack-ai/hotcrm#2753.

Responsibility:

Files to read first (by risk):

  1. ui/packages/app-shell/src/console/AppContent.tsx: the formLinkValues hunk (the URL contract every child create reads).
  2. ui/packages/app-shell/src/views/RelatedRecordActionsBridge.tsx: the onCreate seed and openChildForm hunks.
  3. ui/packages/plugin-detail/src/relatedParentScope.ts.

Two-minute check: on a record whose related tab lists a child with a dependsOn relationship lookup, click Add, then New: the parent shows in its lookup (not "Select ... first"), the dependsOn field is filled, the URL carries two formLink pairs, and Create saves the parent id.

Tests

Pins, each a top-level describe for #37246 in the existing harness of the code it covers:

  • RelatedRecordActionsBridge.createPredicates.test.tsx (the bridge's "+ New" harness): New writes formLink = parent pair then crm_account:acc-1, with and without lookupAutofill; a { field, param } entry and an expanded reference. Controls: no dependsOn, a parent with no account, a custom page's list: the link alone.
  • AppContent.internalFormRetired-36425.test.tsx (the record-form overlay harness, real ModalForm): billing milestone (with lookupAutofill) and contract (without): the relationship lookup is drawn ungated, the opening values hold both, Create posts the parent id and the account. Repeated-pair parse. Control: a lone parent link seeds the parent alone.
  • RelatedList.derivedAddScope-36707.test.tsx (the derived Add harness): relatedCreateSeedOf values and its empty cases. Control: the derived picker keeps its 记录页相关页签「添加」关联已有记录时不按客户过滤,且首列「NAME」为空(商机 → 合同) #36707 scope.
Red on main, green after, ablation
  • Red, the three pins against main's code (the fix files reverted, pins at 5e0a09e127): Test Files 3 failed, Tests 5 failed / 26 passed; e.g. expected [ 'crm_sales_order:so-1' ] to deeply equal [ 'crm_sales_order:so-1', …(1) ]. The reworked overlay pins against main's AppContent.tsx: 3 failed / 7 passed.
  • Green at 951db02b5d: Test Files 3 passed, Tests 49 passed.
  • Ablation (scripts/ablation-replace.mjs, the bridge's relatedCreateSeedOf(...) call replaced by undefined; the test imports the bridge from source, so no dist leg): anchor 1 to 0, 3 failed / 19 passed (the three seed pins; the controls stayed green); restored, blob after restore == HEAD 672ca81d0086, git diff HEAD empty.
  • Reproduction on main (readings, not committed): with main's URL, the overlay drew lookup-trigger-gated "Select Account first" for both children. At the form level, dependsOn: ['account'] plus a lookupAutofill filling account, opened with the parent alone: account filled, the relationship lookup back to "Select…", submit posted the relationship as null. Opened with the seeded account: the relationship kept its record and the autofill still filled its other targets.

Acceptance notes

  • The overlay harness serves its lookups no record read, so it pins the gate and the saved payload, not the label text; the label and the autofill interplay were read at the form level (above).
  • The form's dependent-lookup clear treats the opening lookupAutofill fill as an edit of the field it writes, which is what emptied the order in case 1. The seed sets that field before the form opens, so one level down nothing moves. It does not hold one level further: if the seeded dependsOn field is itself a lookup with a dependsOn and a lookupAutofill of its own (account dependsOn region, filled from the account), the opening fill writes region, the clear empties account, and the emptied account empties the order. The child then saves unlinked, which main does too. That transitive value cannot be read off the parent record, so the fix belongs in the form's clear, not in this seed: tracked as Related-tab New, two dependsOn levels deep: the form's dependent-lookup clear wipes the seeded parent pair, so the child saves unlinked #37289. A create opened another way, with a relationship value and an empty dependsOn field (a URL prefill), meets the same clear.
  • ObjectDataPage's New from a record trail (the "View all" list) writes formLink with the parent pair alone, so a dependsOn relationship lookup there meets the same gate. Not changed here: tracked as "View all" → New from a record trail on ObjectDataPage still writes only the parent pair, not the dependsOn seed #37290.

Verification

Local suites and type-check at 47db09e (origin/main 1b91538 merged in)
  • pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-detail/: Test Files 418 passed, 1 skipped; Tests 3954 passed, 18 skipped; exit 0.
  • pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/: Test Files 2438 passed, 1 skipped; Tests 23194 passed, 9 skipped; exit 0.
  • pnpm --filter @object-ui/plugin-detail type-check: exit 0. pnpm --filter @object-ui/app-shell type-check: exit 0, after rebuilding @object-ui/plugin-detail (its /core types are read from dist).
  • pnpm check:new-line-citations (ui): 0 new citations, exit 0.
Derived gate families (`dispatch-gates.mjs --commands`, the same list at cbee57c and 47db09e)
Rework round at 8afea3b (L1 REWORK: M1, S1, S2, N2; main not merged)
  • M1: the package-root re-export of relatedCreateSeedOf is dropped (src/index.tsx); the /core export stays. core.ts's header no longer says every /core name is also on the root. The changeset declares Clause-②: yes (widening); the level stays patch, and Metadata-protocol: none stays.
  • N2: a new pin in RelatedList.derivedAddScope-36707.test.tsx covers a two-entry dependsOn. When the parent answers both entries, both fields are seeded. When it answers only one, neither is seeded, and the derived picker offers none either.
  • Pins plus pluginCoreSubpaths-33581.test.ts: Test Files 4 passed, Tests 53 passed.
  • pnpm --filter @object-ui/plugin-detail type-check: exit 0. pnpm --filter @object-ui/app-shell type-check: exit 0, after rebuilding plugin-detail's dist.
  • Derived families: the same 46 as before. 44 exit 0, check:type-check-debt included. --ran reports 45 run and 1 NOT MEASURED. NOT MEASURED: check:dual-build-cjs-loads (needs a full build, exit 3) and pnpm --dir ui exec vitest run scripts/ (lock timeout, exit 99). CI carries both.
  • CI at 8afea3b: the 12 required check-runs are success (47 success, 11 skipped).

Generated by Claude Code

…endsOn fields from the parent (#37246)

The New pre-linked the parent alone, so a child relationship lookup that
declares dependsOn drew gated (the parent hidden), or its lookupAutofill
filled the account and the dependent clear emptied the parent, and the
child saved unlinked. The bridge now seeds each dependsOn field from the
parent record (relatedCreateSeedOf, the pairs the derived Add picker scopes
by), carried as repeated formLink pairs the record-form overlay reads.

Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 25, 2026
…ooks/globals)

Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D

Final head for L1 (p1) · area a4-U · 2026-11-25T12:26Z
Head-sha: 0b356e4028a6a6aa74fc2c05a60c5da82ea4907d

Card #37246. Dev report: 7162330362.

  • Root cause: a related tab's New, both the header's and the one inside the Add picker, opened the child's create form carrying only the parent link (one formLink pair).

    • When the child's relationship lookup declares dependsOn, the form drew that lookup gated ("Select Account first") and hid the parent.
    • When it also has a lookupAutofill, the opening fill wrote the account, the dependent-lookup clear then emptied the parent, and the child saved with the relationship null.
  • Fix:

  • Pins, each a top-level describe for console: a related tab's New drops the parent it prefills when the child's relationship lookup declares dependsOn, and saves the child unlinked #37246 in an existing harness:

    • AppContent.internalFormRetired-36425.test.tsx renders the real ModalForm. For the billing milestone (with autofill) and the contract (without), the relationship lookup is ungated, initialValues hold the parent and crm_account, and Create posts both. It also pins the repeated-pair parse, with a lone-link control.
    • RelatedRecordActionsBridge.createPredicates.test.tsx pins the URL New writes, with controls for no dependsOn, a parent with no account, and parentFromList.
    • RelatedList.derivedAddScope-36707.test.tsx has a control showing the 记录页相关页签「添加」关联已有记录时不按客户过滤,且首列「NAME」为空(商机 → 合同) #36707 picker scope is unchanged, and pins relatedCreateSeedOf.
  • Red on main: fix reverted with pins at head: 5 failed, 26 passed (31). Green: 49 of 49.

  • Ablation: the bridge's relatedCreateSeedOf(...) call replaced by undefined: the 3 seed pins go red, the controls stay green. Restored to blob == HEAD.

  • Readings, from the dev:

    • plugin-detail 3954 passed;
    • app-shell 23194 passed;
    • both type-checks exit 0.
  • Gates, from the dev: 45 of 46 dispatch-gates families exit 0. NOT MEASURED:

    • check:dual-build-cjs-loads (needs a full build; prerequisite not met);
    • the ui scripts/ vitest (shared-lock timeouts).

    CI's Lint UI was red on 47db09e7 (a test probe reassigned an outer variable) and is fixed at this head.

  • Out of scope, in Acceptance notes, not filed:

    • ObjectDataPage's New from a record trail ("View all") also writes the parent pair alone, so it is the same family.
    • The opening lookupAutofill fill is treated as an edit by the dependent-lookup clear; it is no longer reached from related New.
    • The first case of AppContent.internalFormRetired failed once under box load (default 1000 ms waitFor while the lazy ModalForm loads).
  • Serial: Related list offers + New for a child whose FK to the parent is readonly; the created record silently loses the link #37248 touches the bridge's onCreate/openChildForm hunks this PR changes, so it is dispatched after this lands.

  • Size: +391 −46 across 12 files.

  • Check-runs at this head: 47 success, 11 skipped, 0 failing or pending.

  • K: 15 against current main. Main will be merged through the relay's pr_update_branch before landing.

Handed to the seat session for L1.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — REWORK · L1 · head 0b356e4028a6a6aa74fc2c05a60c5da82ea4907d · 2026-11-25T12:41Z

…geset declares the widening (#37246)

Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D

Final head for the delta read and the contract review (rework round 1, p1) · area a4-U · 2026-11-25T13:37Z
Head-sha: 8afea3b3daabed7d5ee9e1edccf2af324e46085c

Against REWORK 7162744164. Dev report: 7163964178. This is one commit on top of 0b356e40, with no main merge.

Handed to the seat session for the delta L1 and the TIER_DEFAULT contract review.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — ACCEPT · L1 · head 8afea3b3daabed7d5ee9e1edccf2af324e46085c · 2026-11-25T13:51Z

Delta read against REWORK 7162744164 (head 0b356e4028). The PR is ready at this head. The one finding the delta read raised was a seat-side write on the card, and the seat has made it, so no dev round and no new head.

Verified at this head

No must-fix, no should-fix.

  • Landing: the zone lands it. K = 24 (≥ 15), so main is merged first (pr_update_branch); that merge-only head move needs a merge-only delta read of this L1 and of the contract record at the new head before the PR is enqueued.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 8afea3b3daabed7d5ee9e1edccf2af324e46085c
Local-runs: probe — the seat L1's pin and ablation runs at this head in a throwaway worktree (removed); no judgment below rests on them

① Derived judgments

  • The face is the declaration face, so the tier is TIER_DEFAULT.
    • The committed tree touches no packages/spec/src/** and no governed path.
    • record-recognisers.mjs --template --paths on the 11 net paths decides no face and defers to the changeset's Clause-②: line. That line reads declared / yes / widening through readClause2Line, with no (narrowing) arm, so the face is --face declaration.
  • Declarations at this head:
  • The published surface. @object-ui/plugin-detail has no private, and its exports are . and ./core.
    • Net diff vs merge base 1b91538bb2: src/core.ts adds one line, export { relatedCreateSeedOf } from './relatedParentScope';.
    • src/index.tsx is untouched: the root's names are byte-identical to main.
    • /core's other 17 names are unchanged, and each is still on the root.
  • Pure widening.
    • The new name's signature takes childFields as unknown, referenceField as string | undefined and parentRecord as a string-keyed record of unknown (or undefined), and returns a string-to-string record. It reaches no named type, so no new type joins the declaration closure.
    • dependsOnFromParent and DependsOnValue are exported from the module only. The module is not an entry, and neither entry re-exports them, so they are not on the published surface.
    • No required member is added to any existing interface or props type.
    • Nothing is removed, renamed or retyped.
    • derivedAddOf's behaviour is unchanged. parentScopeOf (module-private) now calls the moved inversion. The prior L1 checked that equivalence line by line, and the 记录页相关页签「添加」关联已有记录时不按客户过滤,且首列「NAME」为空(商机 → 合同) #36707 pins stay green at this head.
  • formLink. Accepting repeated formLink pairs widens the console overlay's URL parse in @object-ui/app-shell (private).
    • A single pair parses as before (pinned control).
    • It is no package API, and it is consistent with a widening declaration.
  • Precedent. perf(console): the first load stops downloading the grid and detail packages #36336 (2b570445bbb) added /core exports and declared Clause-②: yes (widening). This PR declares the same, so the declaration is true.

② Semver level

③ Boundary flags

Implemented-by: claude/issue-37246-related-new-dependson-prefill
Reviewed-by: session_01QSeKYpEsWWE9Y5YtSsDgqZ

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — ACCEPT · L1 · head 58039ed842bd44bc75dfa4a1cafd64d51f3a4bbe · 2026-11-25T14:15Z

  • Merge-only delta over the ACCEPT at 8afea3b3. Head 58039ed8 is pr_update_branch's merge commit (parents 8afea3b3 and main 08bf7d2a).
  • The PR's own change is byte-identical: the old merge base to 8afea3b3 and the new merge base to 58039ed8 carry the same changed lines (11 files, +402/−48). The main changes to RelatedList.tsx and urlParams.ts came from main, and the merge took them without conflict.
  • Check-runs at head: 47 success, 11 skipped, 0 failed. git merge-tree against current origin/main is clean.
  • The card's claim reads declared / yes / widening (7156079705). A same-head TIER_DEFAULT contract record reading PASS is posted beside this one.
  • No must-fix, no should-fix.
  • Landing: the zone readies and enqueues it.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 58039ed842bd44bc75dfa4a1cafd64d51f3a4bbe
Local-runs: none
Scope: ui/packages/plugin-detail/src/core.ts

① Derived judgments

  • Merge-only delta over the PASS record at 8afea3b3 (posted on this PR). Head 58039ed8 is a merge commit: its first parent is 8afea3b3 and its second is main 08bf7d2a. It was made by pr_update_branch.
  • The PR's own change is byte-identical. The diff from merge base 1b91538b to 8afea3b3, and from the new merge base 08bf7d2a to 58039ed8, carry the same added and removed lines: 11 files, +402/−48. The one /core export relatedCreateSeedOf and the root entry are unchanged, so the previous judgments stand.

② Semver level

  • Unchanged: Clause-②: yes (widening), Metadata-protocol: none, patch on all three packages.

③ Boundary flags

  • None new. Check-runs at this head: 47 success, 11 skipped, 0 failed. git merge-tree against current origin/main is clean.

④ Design judgment

  • Holds as at 8afea3b3.

Implemented-by: claude/issue-37246-related-new-dependson-prefill
Reviewed-by: session_01QSeKYpEsWWE9Y5YtSsDgqZ

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D

Landing · area a4-U · 2026-11-25T14:18Z · head 58039ed842bd44bc75dfa4a1cafd64d51f3a4bbe

reading value
L1 merge-only delta ACCEPT, plus the same-head TIER_DEFAULT contract record PASS (seat repo:objectstack#4), at this head: 7165021844, 7165038929. These sit over the delta ACCEPT and contract PASS at 8afea3b3
Clause-② yes (widening): one export, relatedCreateSeedOf, on @object-ui/plugin-detail/core. The claim comment 7156079705 now reads it (the seat's edit)
check-governed-merges.mjs --pr 37283 NOT governed · ≤ 3000 changed lines
check-runs at this head 47 success, 11 expected skip, 0 failed, 0 pending
K was 24 at 8afea3b3, so main was merged by the relay's pr_update_branch; the PR's own lines are byte-identical across the merge (seat)
overlap-check clean

State change: ready for review, and auto-merge is armed. The queue lands it. On MERGED, #37246 closes through Fixes #37246. Follow-ups: #37289 and #37290; #37248 rebases after this lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

console: a related tab's New drops the parent it prefills when the child's relationship lookup declares dependsOn, and saves the child unlinked

2 participants